package com.example.arithmeticleetcode.learnArithmetic.twonodetree.improve;


import com.example.arithmeticleetcode.learnArithmetic.twonodetree.Person;
import com.example.arithmeticleetcode.learnArithmetic.twonodetree.util.BinaryTrees;

import java.util.Comparator;

/**
 * @program: arithmetic-leetcode
 * @description:
 * @author: FangZhen
 * @create: 2020-08-25 18:02
 **/
public class BSTTest {

    private static class PersonComparator implements Comparator<Person> {


        @Override
        public int compare(Person e1, Person e2) {
            return e1.getAge() - e2.getAge();
        }
    }

    private static class PersonComparator2 implements Comparator<Person> {


        @Override
        public int compare(Person e1, Person e2) {
            return e2.getAge() - e1.getAge();
        }
    }

    static void test1() {
        Integer[] arr = new Integer[]{7, 4, 9, 2, 5, 8, 11, 3};
        BST<Integer> bst = new BST<>();
        for (int i = 0; i < arr.length; i++) {
            bst.add(arr[i]);
        }
        BinaryTrees.println(bst);
        System.out.println();
        bst.remove(7);

        System.out.println();
        BinaryTrees.println(bst);
    }

    public static void main(String[] args) throws Exception {
        test1();

//        String srcString = "我们是中国人";
//        String utf2GbkString = new String(srcString.getBytes("UTF-8"),"GBK");
//        System.out.println("UTF-8转换成GBK："+utf2GbkString);
//        String utf2Gbk2UtfString = new String(utf2GbkString.getBytes("GBK"),"UTF-8");
//        System.out.println("UTF-8转换成GBK再转成UTF-8："+utf2Gbk2UtfString);
//
//        System.out.println("=========================================");
//
//        String srcString1 = "我们是中国人";
//        String gbk2UtfString = new String(srcString1.getBytes("GBK"), "UTF-8");
//        System.out.println("GBK转换成UTF-8：" + gbk2UtfString);
//        String gbk2Utf2GbkString = new String(gbk2UtfString.getBytes("UTF-8"), "GBK");
//        System.out.println("GBK转换成UTF-8再转成GBK：" + gbk2Utf2GbkString);


    }
}
